﻿using DevExpress.XtraGrid.Demos.util;
using DXApplicationTangche.Const;
using DXApplicationTangche.DTO;
using DXApplicationTangche.UC.成品出库单.service;
using DXApplicationTangche.UC.标签打印.Service;
using DXApplicationTangche.UC.盘点.Service;
using DXApplicationTangche.UC.订单一览新.销售确认单;
using mendian;
using Microsoft.Office.Interop.Excel;
using NPOI.SS.UserModel;
using NPOI.XSSF.UserModel;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace DXApplicationTangche.UC.门店出入库.Service
{
    public class 出入库Service
    {
        public List<garmentStockOwnerShipIndexDTO> garmentStockOwnerShipIndexDTOs { get; set; }
        public TagPrintDTO tagPrintDTO { get; set; } = new TagPrintDTO();
        public GarmentSaleOut garmentSaleOut = new GarmentSaleOut();

        /// <summary>
        /// 扫货号取得相同款式面料的款式在库一览
        /// </summary>
        /// <param name="barcode"></param>
        /// <returns></returns>
        public static List<ViewStockInDetailDTO> getViewStockInDetailByBarcode(String barcode)
        {
            return
                FunctionHelper.JsonDeserialization<List<ViewStockInDetailDTO>>(
                    RestCall.httpGetMethod(
                        URL.接口url + "/stock/getViewStockInDetailByBarcode?barcode=" + barcode
                        )
                    );
        }
        
        /// <summary>
        /// 扫描成衣码查询成衣信息
        /// </summary>
        /// <param name="barcode"></param>
        /// <returns></returns>
        public static TagPrintDTO get成衣ByBarcode(String barcode)
        {
            return
                FunctionHelper.JsonDeserialization<TagPrintDTO>(
                    RestCall.httpGetMethod(
                        URL.接口url + "/garment/generateSaleInfoByBarcode?barcode=" + barcode
                    )
                );
        }
        /// <summary>
        /// 淘宝成衣出库，返回包装码
        /// </summary>
        /// <returns></returns>
        public static String post生成成衣包装贴(
            String contact,
            String mobile,
            String province,
            String city,
            String county,
            String address,
            String postCode,
            List<TagPrintDTO> tagPrintDTOs)
        {
            try
            {
                return
                    RestCall.PostHttp(
                            URL.接口url + "/garment/savePackageInfo?contact=" + contact
                                        + "&mobile=" + mobile
                                        + "&province=" + province
                                        + "&city=" + city
                                        + "&county=" + county
                                        + "&address=" + address
                                        + "&postCode=" + postCode,
                            FunctionHelper.JsonSerialization(tagPrintDTOs)
                        );
            }
            catch
            {
                return null;
            }
        }
        /// <summary>
        /// 淘宝未发运成衣包装一览
        /// </summary>
        /// <returns></returns>
        public static List<GarmentPackageInfoDTO> get未发运成衣包装一览()
        {
            try
            {
                return
                    FunctionHelper.JsonDeserialization<List<GarmentPackageInfoDTO>>(
                        RestCall.httpGetMethod(
                            URL.接口url + "/garment/getUnDeliveryGarment?pageIndex=" + 0 + "&pageSize=" + 1000
                            )
                        );
            }
            catch
            {
                return new List<GarmentPackageInfoDTO>();
            }

        }
        /// <summary>
        /// 淘宝已发运成衣包装一览
        /// </summary>
        /// <returns></returns>
        public static List<GarmentPackageInfoDTO> get已发运成衣包装一览()
        {
            try
            {
                return
                    FunctionHelper.JsonDeserialization<List<GarmentPackageInfoDTO>>(
                        RestCall.httpGetMethod(
                            URL.接口url + "/garment/getDeliveryGarment?pageIndex=" + 0 + "&pageSize=" + 1000
                            )
                        );
            }
            catch
            {
                return new List<GarmentPackageInfoDTO>();
            }
        }
        /// <summary>
        /// 淘宝成衣顺丰打印订单
        /// </summary>
        /// <returns></returns>
        public static DTO发运 get成衣顺丰打印订单(String packageBarcode, int size)
        {
            return
                FunctionHelper.JsonDeserialization<DTO发运>(
                    RestCall.httpGetMethod(
                        URL.接口url + "/garment/sfExpressOrderByPackageBarcode?packageBarcode=" + packageBarcode + "&size=" + size.ToString()
                        )
                    );
        }
        /// <summary>
        /// 扫包装码获取包装信息
        /// </summary>
        /// <param name="packageBarcode"></param>
        /// <returns></returns>
        public static GarmentPackageInfoDTO get包装信息(String packageBarcode)
        {
            return
                FunctionHelper.JsonDeserialization<GarmentPackageInfoDTO>(
                    RestCall.httpGetMethod(
                        URL.接口url + "/garment/getGarmentPackageInfoById?packageBarcode=" + packageBarcode
                        )
                    );
        }
        /// <summary>
        /// 手机发，扫描保存快递单号
        /// </summary>
        /// <param name="packageBarcode"></param>
        /// <param name="sfExpressNo"></param>
        /// <returns></returns>
        public static String get保存包装码和快递单(String packageBarcode, String sfExpressNo)
        {
            return
                RestCall.httpGetMethod(
                    URL.接口url + "/garment/saveSfExpressNo?packageBarcode=" + packageBarcode + "&sfExpressNo=" + sfExpressNo
                    );
        }
        /// <summary>
        /// 门店扫码入库等候
        /// </summary>
        /// <param name="inOutCode"></param>
        /// <param name="storeId"></param>
        /// <returns></returns>
        public static List<StockInOutDetailDTO> getStockOutToInHold(String inOutCode)
        {
            return
                FunctionHelper.JsonDeserialization<List<StockInOutDetailDTO>>(
                    RestCall.httpGetMethod(
                        URL.接口url + "/store/getStockOutToInHold?inOutCode=" + inOutCode
                        )
                    );
        }

        /// <summary>
        /// 门店扫码入库等候取抬头
        /// </summary>
        /// <param name="inOutCode"></param>
        /// <param name="storeId"></param>
        /// <returns></returns>
        public static StockInOutTitleDTO getStockOutToInTitle(String inOutCode)
        {
            return
                FunctionHelper.JsonDeserialization<StockInOutTitleDTO>(
                    RestCall.httpGetMethod(
                        URL.接口url + "/store/getStockOutToInTitle?inOutCode=" + inOutCode
                        )
                    );
        }
        /// <summary>
        /// 当入库时扫到一个出库单里没有的成衣条码是取出他的信息
        /// </summary>
        /// <param name="barcode">成衣条码</param>
        /// <param name="storeId">店铺Id</param>
        /// <returns>分录信息</returns>
        public static StockInOutDetailDTO getStockInOutDetailDaoWhenExtraIn(String barcode, String storeId)
        {
            return
                FunctionHelper.JsonDeserialization<StockInOutDetailDTO>(
                    RestCall.httpGetMethod(
                        URL.接口url + "/store/getStockInOutDetailDaoWhenExtraIn?barcode=" + barcode + "&storeId=" + storeId
                        )
                    );
        }
        /// <summary>
        /// 其他入库
        /// </summary>
        /// <param name="barcode"></param>
        /// <param name="storeId"></param>
        /// <returns></returns>
        public static StockInOutDetailDTO otherStockIn(String barcode, String storeId)
        {
            return
                FunctionHelper.JsonDeserialization<StockInOutDetailDTO>(
                    RestCall.httpGetMethod(
                        URL.接口url + "/store/otherStockIn?barcode=" + barcode + "&storeId=" + storeId
                        )
                    );
        }
        /// <summary>
        /// 根据库存id查询库存
        /// </summary>
        /// <param name="storeId"></param>
        /// <returns></returns>
        public static List<StockInOutDetailDTO> getInStockInventoryByStoreId(String storeId)
        {
            return
                FunctionHelper.JsonDeserialization<List<StockInOutDetailDTO>>(
                    RestCall.httpGetMethod(
                        URL.接口url + "/store/getInStockInventoryByStoreId?storeId=" + storeId
                        )
                    );
        }
        /// <summary>
        /// 成衣码报废处置
        /// </summary>
        /// <param name="barcode"></param>
        /// <returns></returns>
        public static StockInOutDetailDTO scrapGarment(String barcode,String assignee)
        {
            return
                FunctionHelper.JsonDeserialization<StockInOutDetailDTO>(
                    RestCall.httpGetMethod(
                        URL.接口url + "/store/scrapGarment?barcode=" + barcode + "&assignee=" + assignee
                        )
                    );
        }
        /// <summary>
        /// 门店扫码入库确认
        /// </summary>
        /// <param name="inOutCode"></param>
        /// <param name="storeId"></param>
        /// <param name="storeName"></param>
        /// <param name="mnemonic"></param>
        /// <param name="stockInOutDetailDaos"></param>
        /// <returns></returns>
        public static StockInOutTitleDTO saveStockOutToInConfirm(
            String inOutCode,
            String inStoreId,
            String mnemonic,
            List<StockInOutDetailDTO> stockInOutDetailDaos
            )
        {
            return
                FunctionHelper.JsonDeserialization<StockInOutTitleDTO>(
                    RestCall.PostHttp(
                        URL.接口url + "/store/saveStockOutToInConfirm?inOutCode=" + inOutCode +
                        "&inStoreId=" + inStoreId +
                        "&mnemonic=" + mnemonic,
                        FunctionHelper.JsonSerialization(stockInOutDetailDaos)
                        )
                    );
        }
        /// <summary>
        /// 门店销售出库
        /// </summary>
        /// <param name="barcode"></param>
        /// <param name="storeId"></param>
        /// <param name="storeName"></param>
        /// <param name="mnemonic"></param>
        /// <returns></returns>
        public static StockInOutTitleDTO saveStockSaleOut(
            String sessionId,
            String outStoreId,
            String outStoreName,
            String mnemonic,
            String customerName,
            String customerSex,
            String customerMobile,
            String customerAddress
            )
        {
            return
                FunctionHelper.JsonDeserialization<StockInOutTitleDTO>(
                    RestCall.httpGetMethod(
                        URL.接口url + "/store/saveStockSaleOut?sessionId=" + sessionId +
                        "&outStoreId=" + outStoreId +
                        "&outStoreName=" + outStoreName +
                        "&mnemonic=" + mnemonic +
                        "&customerName=" + customerName +
                        "&customerSex=" + customerSex +
                        "&customerMobile=" + customerMobile +
                        "&customerAddress=" + customerAddress
                        )
                    );
        }

        /// <summary>
        /// 门店现货销售出库带承担人和支付方式
        /// </summary>
        /// <param name="barcode"></param>
        /// <param name="storeId"></param>
        /// <param name="storeName"></param>
        /// <param name="mnemonic"></param>
        /// <returns></returns>
        public static StockInOutTitleDTO storeSaveStockSaleOutWith(
            String outStoreId,
            String outStoreName,
            String mnemonic,
            String customerName,
            String customerSex,
            String customerMobile,
            String customerAddress,
            String sales,
            String paymentType,
            List<GarmentSaleConfirmDTO> garmentSaleConfirmDTOs
            )
        {
            return
                FunctionHelper.JsonDeserialization<StockInOutTitleDTO>(
                    RestCall.PostHttp(
                        URL.接口url + "/store/storeSaveStockSaleOutWith?outStoreId=" + outStoreId +
                        "&outStoreName=" + outStoreName +
                        "&mnemonic=" + mnemonic +
                        "&customerName=" + customerName +
                        "&customerSex=" + customerSex +
                        "&customerMobile=" + customerMobile +
                        "&customerAddress=" + customerAddress +
                        "&sales=" + sales +
                        "&paymentType=" + paymentType,
                        FunctionHelper.JsonSerialization(garmentSaleConfirmDTOs)
                        )
                    );
        }
        /// <summary>
        /// 门店销售退货
        /// </summary>
        /// <param name="barcode"></param>
        /// <param name="storeId"></param>
        /// <param name="storeName"></param>
        /// <param name="mnemonic"></param>
        /// <returns></returns>
        public static String saveStockSaleReturnIn(
            String barcode,
            String storeId,
            String storeName,
            String mnemonic
            )
        {
            return
                RestCall.httpGetMethod(
                        URL.接口url + "/store/saveStockSaleReturnIn?barcode=" + barcode +
                        "&inStoreId=" + storeId +
                        "&inStoreName=" + storeName +
                        "&mnemonic=" + mnemonic
                        );
        }
        /// <summary>
        /// 返厂入库添加等候
        /// </summary>
        /// <param name="sessionId"></param>
        /// <param name="barcode"></param>
        /// <param name="storeId"></param>
        /// <param name="inOutType"></param>
        /// <returns></returns>
        public static StockInOutDetailDTO preStockReturnInByBarcode(
            String sessionId,
            String barcode,
            String inOutType
            )
        {
            switch (inOutType)
            {
                case StockInOutTypeConst.ShopGiftReturnIn:
                    return
                        FunctionHelper.JsonDeserialization<StockInOutDetailDTO>(
                            RestCall.httpGetMethod(
                                URL.接口url + "/store/preStockShopGiftReturnInByBarcode?sessionId=" + sessionId +
                                "&barcode=" + barcode +
                                "&storeId=5"
                                )
                            );
                case StockInOutTypeConst.DefectiveReturnIn:
                    return
                        FunctionHelper.JsonDeserialization<StockInOutDetailDTO>(
                            RestCall.httpGetMethod(
                                URL.接口url + "/store/preStockDefectiveReturnInByBarcode?sessionId=" + sessionId +
                                "&barcode=" + barcode +
                                "&storeId=5"
                                )
                            );
                default:
                    return new StockInOutDetailDTO();
            }
        }
        /// <summary>
        /// 将返厂入库明细表头和分录存入数据库
        /// </summary>
        /// <param name="barcode"></param>
        /// <param name="mnemonic"></param>
        /// <param name="outStoreId"></param>
        /// <param name="outStoreName"></param>
        /// <param name="inOutType"></param>
        /// <param name="remarks"></param>
        /// <returns></returns>
        public static StockInOutTitleDTO saveStockReturnIn(
            String sessionId,
            String outStoreId,
            String outStoreName,
            String mnemonic,
            String inOutType,
            String remarks
            )
        {
            switch (inOutType)
            {
                //礼品返厂
                case StockInOutTypeConst.ShopGiftReturnIn:
                    return
                        FunctionHelper.JsonDeserialization<StockInOutTitleDTO>(
                            RestCall.httpGetMethod(
                                URL.接口url + "/store/saveStockShopGiftReturnIn?sessionId=" + sessionId +
                                "&outStoreId=" + outStoreId +
                                "&outStoreName=" + outStoreName +
                                "&mnemonic=" + mnemonic +
                                "&remarks=" + remarks
                                )
                            );
                //残次返厂
                case StockInOutTypeConst.DefectiveReturnIn:
                    return
                        FunctionHelper.JsonDeserialization<StockInOutTitleDTO>(
                            RestCall.httpGetMethod(
                                URL.接口url + "/store/saveStockDefectiveReturnIn?sessionId=" + sessionId +
                                "&outStoreId=" + outStoreId +
                                "&outStoreName=" + outStoreName +
                                "&mnemonic=" + mnemonic +
                                "&remarks=" + remarks
                                )
                            );
                default:
                    return new StockInOutTitleDTO();
            }
        }

        public static void SaveDataToExcelFile(List<StockInOutDetailDTO> StockInOutDetailDTOs)
        {
            System.Windows.Forms.FolderBrowserDialog sFD = new System.Windows.Forms.FolderBrowserDialog();
            System.Windows.Forms.DialogResult rdr = sFD.ShowDialog();
            string filePath = sFD.SelectedPath;
            XSSFWorkbook workbook = new XSSFWorkbook();
            ISheet sheet = null;
            filePath = filePath + "\\" + DateTime.Now.ToString("yyyy年MM月dd日HH时mm分") + "成衣在库和在途一览.xlsx";
            FileStream fileStream = new FileStream(filePath, FileMode.OpenOrCreate, FileAccess.ReadWrite);
            int i = 0;
            try
            {
                sheet = workbook.CreateSheet(DateTime.Now.ToString("yyyy年MM月dd日HH时mm分") + "成衣在库和在途一览");
                IRow rowTitle = sheet.CreateRow(0);
                rowTitle.CreateCell(0).SetCellValue("出入库类型");
                rowTitle.CreateCell(1).SetCellValue("店铺名称");
                rowTitle.CreateCell(2).SetCellValue("款式");
                rowTitle.CreateCell(3).SetCellValue("尺寸");
                rowTitle.CreateCell(4).SetCellValue("面料号");
                rowTitle.CreateCell(5).SetCellValue("面料名");
                rowTitle.CreateCell(6).SetCellValue("面料成分");
                rowTitle.CreateCell(7).SetCellValue("价格");
                rowTitle.CreateCell(8).SetCellValue("时间");
                rowTitle.CreateCell(9).SetCellValue("成衣条码");
                rowTitle.CreateCell(10).SetCellValue("批号");
                for (i = 0; i < StockInOutDetailDTOs.Count; i++)
                {
                    IRow rowTitle1 = sheet.CreateRow(i + 1);
                    rowTitle1.CreateCell(0).SetCellValue(StockInOutDetailDTOs[i].inOutType);
                    rowTitle1.CreateCell(1).SetCellValue(StockInOutDetailDTOs[i].storeName);
                    rowTitle1.CreateCell(2).SetCellValue(StockInOutDetailDTOs[i].styleNameCn);
                    rowTitle1.CreateCell(3).SetCellValue(StockInOutDetailDTOs[i].styleSizeCd.Substring(15));
                    rowTitle1.CreateCell(4).SetCellValue(StockInOutDetailDTOs[i].fabricCode);
                    rowTitle1.CreateCell(5).SetCellValue(StockInOutDetailDTOs[i].fabricName);
                    rowTitle1.CreateCell(6).SetCellValue(StockInOutDetailDTOs[i].fabricComposition);
                    rowTitle1.CreateCell(7).SetCellValue(StockInOutDetailDTOs[i].price);
                    rowTitle1.CreateCell(8).SetCellValue(StockInOutDetailDTOs[i].salesTime.ToString("yyyy年MM月dd日"));
                    rowTitle1.CreateCell(9).SetCellValue(StockInOutDetailDTOs[i].barcode);
                    rowTitle1.CreateCell(10).SetCellValue(StockInOutDetailDTOs[i].batchNo);
                }
                workbook.Write(fileStream); //写入到excel
                workbook.Close();
            }
            catch (Exception ex)
            {

            }
            //System.Windows.Forms.FolderBrowserDialog sFD = new System.Windows.Forms.FolderBrowserDialog();
            //System.Windows.Forms.DialogResult rdr = sFD.ShowDialog();
            //string filePath = sFD.SelectedPath;
            //filePath = filePath + "\\" + DateTime.Now.ToString("yyyy-MM-dd-HH-mm-ss-ffff") + "成衣在库和在途一览.xls";
            //object misValue = System.Reflection.Missing.Value;
            //Application xlApp = new Microsoft.Office.Interop.Excel.Application();
            //Workbook xlWorkBook = xlApp.Workbooks.Add(misValue);
            //Worksheet xlWorkSheet = (Worksheet)xlWorkBook.Worksheets.get_Item(1);

            ///*PropertyInfo[] props = GetPropertyInfoArray();
            //for (int i = 0; i < props.Length; i++)
            //{
            //    xlWorkSheet.Cells[1, i + 1] = props[i].Name; //write the column name
            //}*/
            //xlWorkSheet.Cells[1, 1] = "出入库类型";
            //xlWorkSheet.Cells[1, 2] = "店铺名称";
            //xlWorkSheet.Cells[1, 3] = "款式";
            //xlWorkSheet.Cells[1, 4] = "尺寸";
            //xlWorkSheet.Cells[1, 5] = "面料号";
            //xlWorkSheet.Cells[1, 6] = "面料名";
            //xlWorkSheet.Cells[1, 7] = "面料成分";
            //xlWorkSheet.Cells[1, 8] = "价格";
            //xlWorkSheet.Cells[1, 9] = "时间";
            //xlWorkSheet.Cells[1, 10] = "成衣条码";
            //xlWorkSheet.Cells[1, 11] = "批号";
            //for (int i = 0; i < StockInOutDetailDTOs.Count; i++)
            //{
            //    xlWorkSheet.Cells[i + 2, 1] = StockInOutDetailDTOs[i].inOutType;
            //    xlWorkSheet.Cells[i + 2, 2] = StockInOutDetailDTOs[i].storeName;
            //    xlWorkSheet.Cells[i + 2, 3] = StockInOutDetailDTOs[i].styleNameCn;
            //    xlWorkSheet.Cells[i + 2, 4] = StockInOutDetailDTOs[i].styleSizeCd;
            //    xlWorkSheet.Cells[i + 2, 5] = StockInOutDetailDTOs[i].fabricCode;
            //    xlWorkSheet.Cells[i + 2, 6] = StockInOutDetailDTOs[i].fabricName;
            //    xlWorkSheet.Cells[i + 2, 7] = StockInOutDetailDTOs[i].fabricComposition;
            //    xlWorkSheet.Cells[i + 2, 8] = StockInOutDetailDTOs[i].price;
            //    xlWorkSheet.Cells[i + 2, 9] = StockInOutDetailDTOs[i].salesTime;
            //    xlWorkSheet.Cells[i + 2, 10] = StockInOutDetailDTOs[i].barcode;
            //    xlWorkSheet.Cells[i + 2, 11] = StockInOutDetailDTOs[i].batchNo;
            //}
            //try
            //{
            //    xlWorkBook.SaveAs(filePath, XlFileFormat.xlWorkbookNormal, misValue, misValue, misValue, misValue, XlSaveAsAccessMode.xlExclusive, misValue, misValue, misValue, misValue, misValue);
            //    xlWorkBook.Close(true, misValue, misValue);
            //    xlApp.Quit();
            //}
            //catch (Exception ex)
            //{

            //}
        }
        /// <summary>
        /// 调拨勾稽校验：验证每天工厂调拨出库是否在两天内完成门店调拨入库
        /// </summary>
        /// <param name="dateStr"></param>
        /// <returns></returns>
        public static List<StockInventoryInOutCheckDTO> stockCheck(String dateStr)
        {
            return
                FunctionHelper.JsonDeserialization<List<StockInventoryInOutCheckDTO>>(
                    RestCall.httpGetMethod(
                        URL.接口url + "/store/stockCheck?dateStr=" + dateStr
                        )
                    );
        }
        public static List<StockInventoryInOutCheckDTO> shopDeliveryStockCheck(String dateStr)
        {
            return
                FunctionHelper.JsonDeserialization<List<StockInventoryInOutCheckDTO>>(
                    RestCall.httpGetMethod(
                        URL.接口url + "/store/shopDeliveryStockCheck?dateStr=" + dateStr
                        )
                    );
        }
        /// <summary>
        /// 确认吊牌工厂入库
        /// </summary>
        /// <param name="barcode"></param>
        /// <returns></returns>
        public static TagPrintDTO garmentWipFactoryStockIn(String barcode)
        {
            return
                FunctionHelper.JsonDeserialization<TagPrintDTO>(
                    RestCall.httpGetMethod(
                        URL.接口url + "/barcode/garmentWipFactoryStockIn?barcode=" + barcode));
        }
        /// <summary>
        /// 吊牌入待检仓
        /// </summary>
        /// <param name="barcode"></param>
        /// <returns></returns>
        public static TagPrintDTO garmentQCWaitStockIn(String barcode)
        {
            return
                FunctionHelper.JsonDeserialization<TagPrintDTO>(
                    RestCall.httpGetMethod(
                        URL.接口url + "/barcode/garmentQCWaitStockIn?barcode=" + barcode));
        }
        /// <summary>
        /// 其他返厂一览
        /// </summary>
        /// <returns></returns>
        public static List<OtherReturnInDTO> getAllOtherReturnIns()
        {
            return
                FunctionHelper.JsonDeserialization<List<OtherReturnInDTO>>(
                    RestCall.httpGetMethod(
                        URL.接口url + "/store/getAllOtherReturnIns"
                        )
                    );
        }
        /// <summary>
        /// 其他返厂的预存缓存
        /// </summary>
        /// <param name="barcode"></param>
        /// <returns></returns>
        public static StockInOutDetailDTO preOtherReturnInByBarcode(String barcode)
        {
            return
                FunctionHelper.JsonDeserialization<StockInOutDetailDTO>(
                    RestCall.httpGetMethod(
                        URL.接口url + "/store/preOtherReturnInByBarcode?barcode=" + barcode));
        }
        /// <summary>
        /// 其他返厂根据缓存Id确认返厂
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public static StockInOutDetailDTO otherReturnInById(String id)
        {
            return
                FunctionHelper.JsonDeserialization<StockInOutDetailDTO>(
                    RestCall.httpGetMethod(
                        URL.接口url + "/store/otherReturnInById?id=" + id));
        }

        /// <summary>
        /// 查询进出库流水合计
        /// </summary>
        /// <returns></returns>
        public static List<ViewStockInventoryDetailDao> getStockInventoryDetails(String inOutFlag, List<String> storeId)
        {
            return
                FunctionHelper.JsonDeserialization<List<ViewStockInventoryDetailDao>>(
                    RestCall.PostHttp(
                        URL.接口url + "/store/getStockInventoryDetails?inOutFlag=" + inOutFlag,
                        FunctionHelper.JsonSerialization(storeId)
                        )
                    );
        }

        /// <summary>
        /// 待入库品类Top10
        /// </summary>
        /// <returns></returns>
        public static List<StockChartDTO> getWaitStickInTop10List()
        {
            return
                FunctionHelper.JsonDeserialization<List<StockChartDTO>>(
                    RestCall.httpGetMethod(
                        URL.接口url + "/store/getWaitStickInTop10List"));
        }
        /// <summary>
        /// 库存查询
        /// </summary>
        /// <param name="storeIds"></param>
        /// <returns></returns>
        public static List<StockQueryFacadeDTO> getStockDetailByStoreIds(List<String> storeIds)
        {
            String xx = FunctionHelper.JsonSerialization(storeIds);
            return
                FunctionHelper.JsonDeserialization<List<StockQueryFacadeDTO>>(
                RestCall.PostHttp(
                URL.接口url + "/inventory/getStockDetailByStoreIds",
                FunctionHelper.JsonSerialization(storeIds)
                )
            );
        }
        /// <summary>
        /// 工厂销售出库，平账用
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public static StockInOutDetailDTO factoryOtherSaleOut(String barcode)
        {
            return
                FunctionHelper.JsonDeserialization<StockInOutDetailDTO>(
                    RestCall.httpGetMethod(
                        URL.接口url + "/store/factoryOtherSaleOut?barcode=" + barcode));
        }
        /// <summary>
        /// 获取商家编码对应库存
        /// </summary>
        /// <param name="barcode"></param>
        /// <returns></returns>
        public static String getSpecNoByBarcode(String barcode)
        {
            return
                RestCall.httpGetMethod(
                    URL.接口url + "/stock/getSpecNoByBarcode?barcode=" + barcode);
        }
        /// <summary>
        /// 每日销售出库明细
        /// </summary>
        /// <returns></returns>
        public static List<StockSpecDTO> getStockSpecAll()
        {
            return 
                FunctionHelper.JsonDeserialization<List<StockSpecDTO>>(
                    RestCall.httpGetMethod(
                        URL.接口url + "/stock/getStockSpecAll")
                    );

        }
        /// <summary>
        /// 扫描流转码和成衣码入库
        /// </summary>
        /// <param name="storeId"></param>
        /// <returns></returns>
        public static StockInventoryDao barcodeStockIn(String stockBarcode, String barcode)
        {
            return
                FunctionHelper.JsonDeserialization<StockInventoryDao>(
                    RestCall.httpGetMethod(
                        URL.接口url + "/store/barcodeStockIn?stockBarcode=" + stockBarcode + "&barcode=" + barcode
                        )
                    );
        }
        /// <summary>
        /// 扫描流转码成衣码出库
        /// </summary>
        /// <param name="barcode"></param>
        /// <returns></returns>
        public static StockInventoryDao barcodeStockOut(String stockBarocde)
        {
            return
                FunctionHelper.JsonDeserialization<StockInventoryDao>(
                    RestCall.httpGetMethod(
                        URL.接口url + "/store/barcodeStockOut?stockBarocde=" + stockBarocde 
                        )
                    );
        }
        /// <summary>
        /// 初始化流转码
        /// </summary>
        /// <param name="barcode"></param>
        /// <returns></returns>
        public static String gerenateStockBarcode()
        {
            return
                RestCall.httpGetMethod(
                        URL.接口url + "/store/gerenateStockBarcode"
                    );
        }
    }

    public class StockSpecDTO
    {
        public String specNo { get; set; }
        public int barcodeCount { get; set; }
        public StockSpecDTO()
        {

        }
    }
    public class DTO发运 //淘宝未发运成衣包装发运返回 
    {
        public String errorCode { get; set; }
        public String errorMessage { get; set; }
        public String orderReqContactInfo { get; set; }
        public String sfExpressNo { get; set; }
        public DTO发运()
        {

        }

    }
    public class GarmentPackageInfoDTO // 淘宝包装码
    {
        public String packageBarcode { get; set; } //包装码
        public String contact { get; set; } //联系人
        public String mobile { get; set; } //电话
        public String province { get; set; } //省
        public String city { get; set; } //市
        public String county { get; set; } //县
        public String address { get; set; } //详细地址
        public String postCode { get; set; } //邮编
        public List<TagPrintDTO> tagPrintDTOS { get; set; } //成衣内容
        public String sfExpressNo { get; set; } //快递单号
        public Boolean delivery { get; set; } //   //  是否发运
        public DateTime createDate { get; set; } //时间
        public GarmentPackageInfoDTO()
        {

        }
    }
    public class GarmentSaleOut
    {
        public String id { get; set; }
        public String garmentBarcode { get; set; }  //  成衣吊牌
        public String ownerShipId { get; set; } //  归属id
        public String ownerShip { get; set; } //  归属
        public Boolean saleOut { get; set; } //    是否已售出
        public DateTime recordDate { get; set; }  //  记录时间
        public GarmentSaleOut()
        {

        }
    }
    public class garmentStockOwnerShipIndexDTO
    {
        public String id { get; set; }
        public String name { get; set; }

        //无参构造函数
        public garmentStockOwnerShipIndexDTO()
        {

        }

        public garmentStockOwnerShipIndexDTO(string id, string name)
        {
            this.id = id;
            this.name = name;
        }
    }

    public class TagPrintDTO
    {
        public String batchNo { get; set; }
        public String orderId { get; set; }
        public int orderNumber { get; set; }
        public String styleId { get; set; }
        public String styleNameCn { get; set; }
        public String sytleFabricId { get; set; }
        public String styleSizeCd { get; set; }
        public String materialCode { get; set; }
        public String materialComposition { get; set; }
        public String materialNameCn { get; set; }//面料描述名称
        public List<MeasureItemDTO> measureItemDTOS { get; set; }   //  尺寸值
        public List<String> inventoryNos { get; set; } //  成衣条码
        public String inventoryNo { get; set; } //  成衣条码
        public String styleCategoryCd { get; set; }

        public TagPrintDTO()
        {

        }
    }

    /// <summary>
    /// 调拨勾稽校验DTO
    /// </summary>
    public class StockInventoryInOutCheckDTO
    {
        /*
            工厂出库信息
        */
        public String id { get; set; }
        public String stockOutTitleId { get; set; }//出库表头id
        public String stockOutCode { get; set; }//出库单号
        public String barcode { get; set; }
        public String styleNameCn { get; set; } //  款式名称
        public String styleSizeCd { get; set; }//尺码
        public String fabricCode { get; set; }//面料编码
        public String fabricName { get; set; }//面料名称
        public String fabricComposition { get; set; }//面料成分
        public DateTime stockOutDate { get; set; }  //  工厂出库时间
        public String stockOutStoreName { get; set; }   //  出库门店
        /*
            门店入库信息
         */
        public String stockInTitleId { get; set; }//入库表头id
        public String stockInCode { get; set; }//入库单号
        public DateTime stockInDate { get; set; }  //  门店出库时间
        public String stockInStoreName { get; set; }   //  入库门店
        public StockInventoryInOutCheckDTO()
        {

        }
    }
    public class OtherReturnInDTO
    {
        /**
     * 缓存信息
     */
        public String id { get; set; }
        public String barcode { get; set; }
        public String status { get; set; }  //  状态
        public DateTime createDate { get; set; }    //  创建时间
        public DateTime expirationDate { get; set; }    //  失效时间
        /**
         * 库存信息
         */
        //  款式、面料、尺码
        public String styleNameCn { get; set; } //  款式名称
        public String styleSizeCd { get; set; }//尺码
        public String fabricCode { get; set; }
        public String fabricName { get; set; }
        public String fabricComposition { get; set; }
        //  货号信息
        public String inventory { get; set; }
        public Double price { get; set; }
        public OtherReturnInDTO()
        {

        }
    }

    public class ViewStockInventoryDetailDao
    {
        public String id { get; set; }
        public String storeId { get; set; }
        public String storeName { get; set; }
        public String styleNameCn { get; set; } //  款式名称
        public String styleSizeCd { get; set; } //  尺码
        public String fabricCode { get; set; }  //  面料编码
        public String createDate { get; set; }  //  时间:2022-03-08
        public String stockInOutTimeStamp { get; set; } //  整点时间:2022年03月08日 13点
        public String inOutFlag { get; set; }   //  出入库
        public String inOutType { get; set; }   // 出入库类型
        public int quantity { get; set; }   //  合计数
        public ViewStockInventoryDetailDao()
        {

        }
    }

    public class StockChartDTO
    {
        public String styleNameCn { get; set; }
        public int quantity { get; set; }
        public StockChartDTO()
        {

        }
    }
    public class StockQueryFacadeDTO
    {
        public String styleNameCn { get; set; } //  款式名称
        public String styleSizeCd { get; set; } //  尺码
        public String fabricCode { get; set; }  //  面料编码
        public int quantity { get; set; }   //  合计数
        public List<StockInOutDetailDTO> stockInOutDetailDTOList { get; set; } = new List<StockInOutDetailDTO>();
        public StockQueryFacadeDTO()
        {

        }
    }
    public class StockInventoryDao
    {
        public String stockbarcode { get; set; }
        public int stockIndex { get; set; }
        public String barcode { get; set; }
        public String stylenamecn { get; set; }
        public String fabriccode { get; set; }
        public String size { get; set; }
        public DateTime datetime { get; set; }
        public StockInventoryDao()
        {

        }
    }
}

